Ubuntu 启用 rc.local
创建 rc-local
服务脚本:
- 编辑
/etc/systemd/system/rc-local.service
并添加以下内容:
[Unit]
Description=/etc/rc.local Support
ConditionPathExists=/etc/rc.local
[Service]
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
创建 rc.local
:
- 编辑
/etc/rc.local
并添加以下内容:
#!/bin/bash
exit 0
- 为
rc.local
赋予可执行权限:
chmod +x /etc/rc.local
载入并启用 rc-local
服务:
- 载入
rc-local
服务:
systemctl daemon-reload
- 设置开机启动
rc-local
服务:
systemctl enable rc-local